package com.sphd.emanu.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.emanu.R;
import com.sphd.emanu.pojo.TimeEntity;
import com.wzutils.L;

import java.util.List;

/**
 * @Author Hu
 * @Time 2017/4/20 --14:29.
 * @Email 87683202@qq.com
 */
public class TimeAdapter extends BaseQuickAdapter<TimeEntity, BaseViewHolder> {
    long websiteDatetime;
    Context context;

    public TimeAdapter(int layoutResId, List<TimeEntity> data,Context context) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, TimeEntity item) {
            helper.setText(R.id.time_tv,item.getTimeString());
         TextView tv = helper.getView(R.id.time_tv);
        if (item.getTimeLong()<websiteDatetime){
            item.setCanSelected(false);
            tv.setBackground(ContextCompat.getDrawable(context,R.drawable.bg_color_mygray));
            tv.setTextColor(ContextCompat.getColor(context,R.color.my_gray));
        }else {
            item.setCanSelected(true);
            tv.setBackground(ContextCompat.getDrawable(context,R.drawable.bg_colorgray));
            tv.setTextColor(ContextCompat.getColor(context,R.color.gray));
            if (item.isSelected()){
                tv.setBackground(ContextCompat.getDrawable(context,R.drawable.bg_color_red));
                tv.setTextColor(ContextCompat.getColor(context,R.color.red));
            }
        }



    }


    public void setTime(long websiteDatetime) {
        this.websiteDatetime = websiteDatetime;
    }
}
